package acceptTests;

import java.io.IOException;

import exceptions.database.InvalidUserListException;
import sessionManager.SessionManager;
import sessionManager.SessionManagerIF;
import user.notifier.NotifierManager;

public class US13Facade {

	private SessionManagerIF session;
	private NotifierManager notifier;

	public void cleanPersistence() {
		session.cleanPersistence();

	}

	public US13Facade() {
		session = SessionManager.getInstance();
		notifier = new NotifierManager();

	}

	public void createProfile(String login, String senha, String nome_exibicao,
			String email, String sexo, String dataNasc, String endereco,
			String interesses, String quem_sou_eu, String filmes,
			String musicas, String livros) throws Exception {
		session.createUser(login, senha, nome_exibicao, email, sexo, dataNasc,
				endereco, interesses, quem_sou_eu, filmes, musicas, livros);

	}

	public String logon(String login, String senha) throws Exception {
		return session.loginUser(login, senha);

	}

	public int getNumberOfAnnouncements(String sessionId) throws Exception {

		return notifier.getNumbersOfAnnoucements(sessionId);
	}

	public String createBlog(String idSession, String title, String description)
			throws Exception {
		return session.getUser(idSession).createBlog(idSession, title,
				description);
	}

	public String createPost(String idSession, String blogId, String title,
			String content) throws Exception {

		return session.getUser(idSession).getBlog(blogId)
				.addPost(title, content);
	}

	public void addPostAnnouncements(String sessionId, String blogId)
			throws Exception {
		notifier.createAnnoucement(sessionId, blogId);
	}

	public String getAnnouncement(String sessionId, int index) throws Exception {

		return notifier.getAnnoucement(sessionId, index);
	}

	public String getPostJustCreated(String announcementId) {

		return notifier.getPostJustCreated(announcementId);
	}

	public void deleteAnnouncement(String sessiondId, String announcementId)
			throws Exception {
		notifier.deleteAnnoucement(sessiondId, announcementId);
	}

	public boolean logoff(String sessionID) throws Exception {
		return session.logoffUser(sessionID);
	}

	public void saveData() throws InvalidUserListException, IOException {
		session.saveData();
	}
}